<div class="panel panel-default panel-intro">
    <style>
        .z-status{
            vertical-align: middle;
            margin-bottom: 15px;
        }
        .z-status span{
            color: #415161;
        }
        .form-group label{
            width: 90px;
        }
        .gys{
            margin-left: 15px;
        }
        .z-status b{
            font-size: 18px;
            color: #f96b6b;
        }
        .order{
            display: inline;
            margin-left: 12px;
            font-size: 16px;

        }
        .z-text{
            display: inline;
            margin-left: 15px;
            color: #333333;
            width: 70px;
        }
    </style>
    <?php
     use app\admin\model\halt\Cate;
function getName($name){
        if (empty($name))return;
        $arr = explode(",",$name);
        $model = new Cate();
        $str=array();
        foreach ($arr as $v){
            $info = $model->field('name')->find($v);
    if ($info){
    $str[]=$info['name'];
    }
    }
    return implode(',',$str);
    }
    use app\admin\model\Admin;

    function getusername($userid){
    $admin = new Admin();
    $info = $admin->field("username")->where(array("userid"=>$userid))->find();
    return $info['username'];
    }
    use app\admin\model\Githouse;

    function getcname($id){
    $admin = new Githouse();
    $info = $admin->field("gname")->where(array("id"=>$id))->find();
    return $info['gname'];
    }
    use app\admin\model\Preproduct;
    function getnames($id){
    $admin = new Preproduct();
    $info = $admin->field("cname")->where(array("id"=>$id))->find();
    return $info['cname'];
    }
    $type = isset($_GET['type']) ? intval($_GET['type']) : 1;
    ?>
    <div id="toolbar" class="toolbar" style="position: relative;">

        <div class="panel-heading">
            <ul class="nav nav-tabs">
                <li  {if condition="$type eq 1"}class="active"{/if}><a href="/admin/store/purcha/view/ids/{$info['id']}?dialog=1&type=1" >订单详情</a></li>
                <li {if condition="$type eq 2"}class="active"{/if}><a href="/admin/store/purcha/view/ids/{$info['id']}?dialog=1&type=2" >入库记录</a></li>
                <li {if condition="$type eq 3"}class="active"{/if}><a href="/admin/store/purcha/view/ids/{$info['id']}?dialog=1&type=3" >退货记录</a></li>

            </ul>
        </div>
        <div class="panel-body">
            <div id="myTabContent" class="tab-content">
                <div class="tab-pane fade {if condition="$type eq 1"}active in{/if}" id="first">
                <div class="z-status">

                    <b>{$statusList[$info['status']]}</b>
                    <span class="order">订单号 : {$info.order_id}</span>
                    <span class="gys">供应商 : {$info.supplier}</span>

                </div>
                <div class="form-group">
                    <label>其它金额</label>
                    <span class="z-text">{$info.other_money}</span>
                </div>
                <div class="form-group">
                    <label>创建日期</label>
                    <span class="z-text">{:date('Y-m-d H:i',$info.createtime)}</span>
                </div>
                <div class="form-group">
                    <label>下单人</label>
                    <span class="z-text">{$info.publisher}</span>
                </div>
                <div class="form-group">
                    <label>备注</label>
                    <span class="z-text">{$info.mark}</span>
                </div>
                <table id="table" class="table table-striped table-bordered table-hover" data-operate-edit="1" data-operate-del="1" width="100%">
                    <thead>
                    <tr>
                        <th></th>
                        <th>商品名称</th>
                        <th>印张</th>
                        <th>下单数量</th>
                        <th>已入库数量</th>

                        <th>入库数量</th>
                        <th>下单价格</th>
                        <th>小计</th>
                    </tr>
                    </thead>

                    <tbody>
                    <?php
                        $yi=0;//已经入库
                        $dai=0;//已经入库
                        $num=0;
                        $price=0;
                        $actuals=0;
                    ?>
                    {volist name="list" id="vo"}
                    <?php
                        $num+=$vo['num'];
                        $actuals+=$vo['actual'];
                        $price+=$vo['num']*$vo['price'];
                    ?>
                    <tr>
                        <td>{$key+1}</td>
                        <td>{$vo["shopid"]["cname"]}</td>
                        <td>{$vo["yinzhang"]}</td>
                        <td>{$vo.num}</td>
                        <th>{$vo.actual}</th>
<?php
    $sj=0;
    $sj = $vo['num']-$vo['actual'];
    if($sj <=0){
           $sj=0;
    }
?>

                        <td><input type="text" class="list-qd" shopid="<?php echo $vo["shopid"]["id"];?>" class="form" style="width: 80px" value="{$sj}"></td>

                        <td>{$vo.price}</td>
                        <td>{$vo.num*$vo.price}</td>

                    </tr>

                    {/volist}
                    <tr>
                        <td>合计</td>
                        <td></td>
                        <td></td>
                        <td><?php echo $num;?></td>
                        <td><?php echo $actuals;?></td>
                        <td></td>
                        <td></td>

                        <td style="color:#f96b6b;font-size:18px"><?php echo number_format($price,'2','.',',');?></td>
                    </tr>
                    {if condition="$info['status'] neq 1 && $info['status'] neq 4"}

                    <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>

                            <button  type="button" id="ruku"  data-id="{$vo.pur_id}" class="btn btn-success">入库</button>

                        </td>
                        <td></td>
                        <td style="color:#f96b6b;font-size:18px"></td>
                    </tr>
                    {/if}
                    </tbody>

                </table>

            </div>
            <div class="tab-pane fade {if condition="$type eq 2"}active in{/if} " id="second">
            <table id="table" class="table table-striped table-bordered table-hover" data-operate-edit="1" data-operate-del="1" width="100%">
                <thead>
                <tr>
                    <td>入库单号</td>
                    <td>商品名称</td>
                    <td>入库数量</td>
                    <td>仓库名称</td>
                    <td>操作时间</td>
                    <td>操作人</td>

                </tr>
                </thead>
                <tbody>
                {volist name="wlist" id="vo"}
                <tr>
                    <td>{$vo.order_id}</td>
                    <td>{:getnames($vo['shopid'])}</td>
                    <td>{$vo.num}</td>
                    <td>{:getcname($vo['cid'])}</td>
                    <td>{:date("Y-m-d",$vo['inputtime'])}</td>
                    <td>{:getusername($vo['publisher'])}</td>


                </tr>
                {/volist}
                </tbody>
            </table>
            {$wlist->render()}
        </div>
        <div class="tab-pane fade {if condition="$type eq 3"}active in{/if}" id="three">
        <table class="table">
            <thead>
            <tr>
                <td>退库单号</td>
                <td>商品名称</td>
                <td>商品分类</td>
                <td>数量</td>
                <td>退库时间</td>
                <td>采购单号</td>
                <td>操作人</td>
            </tr>
            </thead>

            </tbody>
        </table>
    </div>
</div>
</div>
</div>